package singleton
{
	import mx.core.Application;
	import mx.modules.Module;
	
	import sdk3.components.remoteService.connectionParameters;
	import sdk3.components.remoteService.user;

	public class singleton_storage
	{
		/** constructor **/
		public function singleton_storage()
		{
			
		}
		private static var instance:singleton_storage = null;
		
		public static function singleton():singleton_storage
		{
			if (instance == null) 
			{
				instance = new singleton_storage();
			}
			return instance;
		}

		public var language:String = "EN"; // default is ENglish

		/** read the config.xml and safe settings into this singleton_storage.singleton().config_xml
		 * config_xml is read from config.xml in the same folder as the APPLICATION.swf you are developing using this library
		 * config.xml contains client-config informations
		 * 1. what settings to use for the client app
		 * 2. how to contact the server.
		 * 3. language
		 * 4. what database to use

  		 * -> language of the app
		 * -> possible values:
		 * DE = GERMAN
		 * EN = ENGLISH
		 * ... more can be implemented, by complementing the string-table in database
		 * **/
		private var _config_xml:Object = {host:'will be read from config.xml',port:'3306',DatabaseName:'will read from a config file from server called: endpoint_xml.config',TableName:'will read from a config file from server called: endpoint_xml.config',type:'mysql',user:'root',password:'',url:'will be read from config.xml',packet_size:300,class_name:'xdbtools',dataEncoding:'amf',SortMode:'ASC',SortField:'',language:'will be read from config.xml'};
		
		public function set config_xml(config_xml_temp:Object):void
		{
			this._config_xml = config_xml_temp;
			
			language = config_xml_temp['config']['system']['language']; // actually this should be stored to & loaded from the server
		}
		public function get config_xml():Object
		{
			return this._config_xml;
		}
		
		private var _connectionParameters:connectionParameters = null;
		
		public function set connectionParameterss(connectionParameters_temp:connectionParameters):void
		{
			this._connectionParameters = connectionParameters_temp;
		}
		public function get connectionParameterss():connectionParameters
		{
			return this._connectionParameters;
		}

		private var _MODULE_template:Module = null;

		public function set MODULE_template(MODULE_template_temp:Module):void
		{
			this._MODULE_template = MODULE_template_temp;
		}
		public function get MODULE_template():Module
		{
			return this._MODULE_template;
		}

		// temp storage for user informations
		private var _USER:user = new user();

		public function set USER(USER_temp:user):void
		{
			this._USER = USER_temp;
		}
		public function get USER():user
		{
			return this._USER;
		}
		
		/** list of all groups **/
		private var _groups:Array = new Array();

		public function set groups(groups_temp:Array):void
		{
			this._groups = groups_temp;
		}
		public function get groups():Array
		{
			return this._groups;
		}
		
		/** in what interval (in seconds) a poll will be automatically done **/
		private var _PollingUpdateInterval:int = 3;

		public function set PollingUpdateInterval(PollingUpdateInterval_temp:int):void
		{
			this._PollingUpdateInterval = PollingUpdateInterval_temp;
		}
		public function get PollingUpdateInterval():int
		{
			return this._PollingUpdateInterval;
		}
	}
}